import BaseItemView from "../../../cfw/mvc/BaseItemView";
import SDKManager from "../../SDKManager";
import GameItemModel from "../../base/GameItemModel";
import BigExportC from "../../appBoxAd/BigExportC";
import ModuleManager from "../../../cfw/module/ModuleManager";
import { ResType } from "../../../cfw/res/ResInterface";
import ResItem from "../../../cfw/res/ResItem";


const { ccclass, property } = cc._decorator;

@ccclass
export default class GameMatrixItemView extends BaseItemView {

	@property({ type: cc.Sprite, displayName: "icon$VSprite" })
	icon$VSprite: cc.Sprite = null;



	protected model: GameItemModel;
	witchExport: number = 0;
	onLoad() {

	}

	refresh() {
		if (this.model) {
			ModuleManager.publicLoader().loadRes(this.model.getGameIcon(), ResType.Remote, (err, tex: ResItem) => {
				if (err || !cc.isValid(this.node)) {
					return;
				}
				this.icon$VSprite.spriteFrame = new cc.SpriteFrame(tex.getRes())
			})
		}

	}


	onDestroy() {

	}

	onButtonClick() {
		SDKManager.getChannel().navigate2Mini(this.model,
			() => { },
			() => {
				switch (this.witchExport) {
					case 0:
						BigExportC.instance().intoExport2()
						break;
					case 1:
						BigExportC.instance().intoExport1(() => {
							BigExportC.instance().intoExport3()
						})
						break;
				}

			})
	}



}